import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '../views/Index/Index.vue'
import show from "../views/Login/Show.vue"


Vue.use(VueRouter)

const routes = [

  {
    path: '/index',
    name: 'index',
    component: index,
    children: [
      {
        path: '',
        name: 'main',
        component: () => import('../views/Index/Main.vue')
      },
      {
        path: 'description',
        name: 'description',
        component: () => import('../views/Index/personal/Description.vue'),
        children: [
          {
            path: '',
            name: 'info',
            component: () => import('../views/Index/personal/Info.vue')
          },
          {
            path: 'info',
            name: 'info',
            component: () => import('../views/Index/personal/Info.vue')
          },
          {
            path: 'passwordman',
            name: 'passwordman',
            component: () => import('../views/Index/personal/PasswordMan.vue')
          },
          {
            path: 'changeemail',
            name: 'changeemail',
            component: () => import('../views/Index/personal/ChangeEmail.vue')
          },
        ]
      },
      {
        path: 'main',
        name: 'main',
        component: () => import('../views/Index/Main.vue')
      },
      {
        // path: 'courseInfo/:videoinfo',
        path: 'courseInfo',
        name: 'courseInfo',
        component: () => import('../views/Index/course/Course-info'),
        props:true
      },
      {
        path: 'course',
        name: 'course',
        component: () => import('../views/Index/course/Course.vue')
      },
      {
        path: 'forum',
        name: 'forum',
        component: () => import('../views/Index/forum/Forum.vue'),
        children:[
          {
            path:"/:list",
            name:"ForumList",
            component:()=>import('../views/Index/forum/ForumList'),
            props: true
          },
          {
            path:"info1/:info",
            name:"Forum-info",
            component:()=>import('../views/Index/forum/Forum-info'),
            props:true
          }
        ]
      },
    ]
  },
  {
    path: '/',
    name: 'show',
    component: show,
    children: [
      {
        path: '',
        name: 'login',
        component: () => import('../views/Login/Login.vue')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import('../views/Login/Register.vue')
      },
      {
        path: 'login',
        name: 'login',
        component: () => import('../views/Login/Login.vue')
      }
    ],
  },
  {
    path: '/app',
    name: 'app',
    component: () => import('../App.vue')
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
//解决vue-router重复点击报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch((err) => err) }
export default router
